package com.szjlc.blog.common.config;

import com.szjlc.blog.common.interceptor.LogInterceptor;
import javax.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 拦截适配器配置
 * @author steve
 * @since 2022-11-28 22:57
 */
@Configuration
public class InterceptorAdapterConfig extends WebMvcConfigurerAdapter {

    /** 你自定义的拦截器 */
    @Resource
    private LogInterceptor logInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册自己的拦截器并设置拦截的请求路径
        registry.addInterceptor(logInterceptor).addPathPatterns("/**");
        super.addInterceptors(registry);
    }
}
